﻿#include "userservice.h"

#include <coredatabase.h>

UserService::UserService(QObject *parent) : QObject(parent)
{
    db = CoreDatabase::getInstance()->getConnection();
}

UserService::~UserService()
{
    CoreDatabase::getInstance()->releaseConnection(db);
}

bool UserService::getPageList(uint64_t &total, QList<User> &users, const uint64_t &page, const uint64_t &pageSize)
{
    UserDao userDao(db);
    return (userDao.getTotalByParam(total) && userDao.getPageListByParam(users,page,pageSize));
}

bool UserService::getOne(User &object)
{
    UserDao userDao(db);
    return userDao.getOne(object);
}

bool UserService::saveOne(User &object)
{
    UserDao userDao(db);
    return userDao.saveOne(object);
}

bool UserService::deleteOne(User &object)
{
    UserDao userDao(db);
    return userDao.deleteOne(object);
}

